package com.hdf.etdemo.view.loading;

import java.util.Timer;
import java.util.TimerTask;

import com.hdf.easytools.base.EasyToolsActivity;
import com.hdf.easytools.loading.LoadingView;
import com.hdf.easytools.loading.ZProgressHUD;
import com.hdf.easytools.loading.monindicator.MonIndicator;
import com.hdf.etdemo.R;
import com.hdf.etdemo.R.layout;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class LoadingActivity extends EasyToolsActivity{
	private LoadingView loadingview;
	 private MonIndicator monIndicator;
	 private ZProgressHUD progressHUD;
	 private Button start,start2,start3;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_loading);
		/**设置标题显示*/
		this.TitleVisib(0, 1, 1, 0, 0);
		/**绑定标题点击事件*/
		this.TitleClick(0, 1, 0, 0, 0);
		/**设置标题样式ʽ*/
		this.TitleStyle(null,R.drawable.et_back, "Loading动画", null,0);
		/**小球进度  start*/
		monIndicator = (MonIndicator)this.findViewById(R.id.monIndicator);
		//格式：0x+透明值+颜色的rgb值
		//0x FF 2172db
		monIndicator.setColors(new int[]{0xFFE95045, 0xFF76C673, 0xFFF8CB10, 0xFF2095EE, 0xFF92B5DA});
		//end
		start=(Button) findViewById(R.id.startdialog);
		start.setOnClickListener(this);
		start2=(Button) findViewById(R.id.startdialog2);
		start2.setOnClickListener(this);
		start3=(Button) findViewById(R.id.startdialog3);
		start3.setOnClickListener(this);
			
	}


	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.left_img:
				finish();
			break;
		case R.id.startdialog:
			openLoading();
			break;
		case R.id.startdialog2:
			openLoading2();
			break;
		case R.id.startdialog3:
			openLoading3();
			break;
		default:
			break;
		}
	}
	/**
	 * 打开loading
	 * @param view
	 */
	private Handler handler = new Handler();
    public void openLoading(){
    	progressHUD = ZProgressHUD.getInstance(this); 
    	progressHUD.setMessage("加载中");
    	progressHUD.setSpinnerType(ZProgressHUD.SIMPLE_ROUND_SPINNER  );
    	progressHUD.show();
    	handler.postDelayed(new Runnable() {

			@Override
			public void run() {
				progressHUD.dismiss();//关闭loading
			}
		}, 10000);
    	
    }
    public void openLoading2(){
    	progressHUD = ZProgressHUD.getInstance(this); 
    	progressHUD.setMessage("Loading...");
    	progressHUD.setSpinnerType(ZProgressHUD.GEAR_SPINNER  );
    	progressHUD.show();
    	handler.postDelayed(new Runnable() {

			@Override
			public void run() {
				progressHUD.dismiss();//关闭loading
			}
		}, 10000);
    	
    }
    public void openLoading3(){
    	progressHUD = ZProgressHUD.getInstance(this); 
    	progressHUD.setSpinnerType(ZProgressHUD.FADED_ROUND_SPINNER);
    	progressHUD.show();
    	handler.postDelayed(new Runnable() {

			@Override
			public void run() {
				progressHUD.dismiss();//关闭loading
			}
		}, 10000);
    	
    }
}
